<?

  ob_start();
  header('content-type: text/html; charset=utf-8');
  profile_point('- page start');
  $killRating = getKillRating($ctrObj->character->charDS);

?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
  <head>
    <base href="<?= $config['site.base'] ?>">
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <link type="text/css" rel="stylesheet" href="themes/default/default.css"/>
    <title><?= $doctitle ?></title>
  <?= implode(' ', $config['pageheaders']) ?>
  </head>
  <body>
    <script type="text/javascript" src="custom/ajax.js"></script>
    <img src="img/icons/beta-badge.png" style="position: absolute; top: 4px; right: 240px;" width="64"/>
    <div id="container">
      <div id="accountmenu" align="right">
        <?= $ctrObj->character->charDS['c_name'] ?>, Level <?= $ctrObj->character->charDS['c_level'] ?>
        <div <?= toolTip(':Alignment: this is your current emotional state, a summary reflection of your past experiences.') ?>>
          alignment: <?= $ctrObj->l10n(
          'alignment.'.$killRating, 'cq'); ?></div>
      </div>
    <div id="quickstatblock">
      <?
      $barWidth = 100;
      if (isset($ctrObj) && isset($ctrObj->character))
      {
        $ctrObj->character->initStats();
        
        $hp = $ctrObj->character->getCharacterStat('HP');
        $hp_total = $ctrObj->character->getCharacterStat('HP', ',.effective');
        $hpc = $hp; if ($hpc < 0) $hpc = 0; if ($hpc > $hp_total) $hpc = $hp_total;
        
        $ap = $ctrObj->character->getCharacterStat('AP');
        $ap_total = $ctrObj->character->getCharacterStat('AP', ',.effective');
        $apc = $ap; if ($apc < 0) $apc = 0; if ($apc > $ap_total) $apc = $ap_total;
        
        $mp = $ctrObj->character->getCharacterStat('MP');
        $mp_total = $ctrObj->character->getCharacterStat('MP', ',.effective');
        $mpc = $mp; if ($mpc < 0) $mpc = 0; if ($mpc > $mp_total) $mpc = $mp_total;
        
        $xp = $ctrObj->character->getCharacterStat('XP');
        $xp_total = $ctrObj->character->xpGoal;
        $xpc = $xp - $ctrObj->character->prevXpGoal;
        $xp_totalc = $ctrObj->character->xpGoal - $ctrObj->character->prevXpGoal;
        
        $level = $ctrObj->character->charDS['c_level'];
      }
      ?>
      <table width="100%" cellpadding="2" cellspacing="1">
        <tr bgcolor="#d0d0d0" <?= toolTip(':Hit Points: how much damage your character can take before keeling over. Regenerates over time (2 every '.$ctrObj->character->tickTime.' seconds) or with healing items bought in the shop.') ?>>
          <td width="5%" nowrap><img align="absmiddle" src="img/icons/hit_points.png"/> HP</td>
          <td nowrap><div align="center"><?= $hp ?> / <?= $hp_total ?></div></td>
          <td width="<?= $barWidth ?>" class="bar_hp_back"><div class="bar_hp" style="width: <?= $barWidth*($hpc/$hp_total) ?>px;">&nbsp;</div></td>
          <td>&nbsp;</td>
        </tr>
        <?
        #if ($ctrObj->character->stats['MP'] > 0)
        {
        ?>
        <tr bgcolor="#d0d0d0" <?= toolTip(':Magic Points: energy for your spells.') ?>>
          <td nowrap><img align="absmiddle" src="img/icons/mp.png"/> MP</td>
          <td nowrap><div align="center"><?= $mp ?> / <?= $mp_total ?></div></td>
          <td width="<?= $barWidth ?>" class="bar_mp_back"><div class="bar_mp" style="width: <?= $barWidth*($mpc/$mp_total) ?>px;">&nbsp;</div></td>
          <td>&nbsp;</td>
        </tr>
        <?
        }
        ?>
        <tr bgcolor="#d0d0d0" <?= toolTip(':Action Points: how much your character can do before needing some nap time. Regenerates over time (1 every '.$ctrObj->character->tickTime.' seconds).') ?>>
          <td nowrap><img align="absmiddle" src="img/icons/action_points.png"/> AP</td>
          <td><div align="center"><?= $ap ?> / <?= $ap_total ?></div></td>
          <td width="<?= $barWidth ?>" class="bar_ap_back"><div class="bar_ap" style="width: <?= $barWidth*($apc/$ap_total) ?>px;">&nbsp;</div></td>
          <td>&nbsp;</td>
        </tr>
        <tr bgcolor="#d0d0d0" <?= toolTip(':Experience Points: points earned for doing stuff, those increase your character\'s level in intervals.') ?>>
          <td nowrap><img align="absmiddle" src="img/icons/experience_points.png" /> XP</td>
          <td nowrap><div align="center"><?= $xp ?> / <?= $xp_total ?></div></td>
          <td width="<?= $barWidth ?>" class="bar_xp_back"><div class="bar_xp" style="width: <?= $barWidth*($xpc/$xp_totalc) ?>px;">&nbsp;</div></td>
          <td>&nbsp;</td>
        </tr>
      </table>
      
    </div>
	  <div id="topmenu"><? 
        foreach ($config['menu'] as $item) { ?>
        <a <?= $item['style'] ?> href="<?= $item['url'] ?>"><?= $item['caption'] ?></a>
      <? } 
        profile_point('- account menu');
      ?></div>
      <h1>
        <?= getDefault($config['pagetitle'], $config['site.name']) ?>
      </h1>
      <div id="content">
        <!--<div class="banner">The server is being updated right now, intermitted outages may occur.</div>-->
        <?
        if ($ctrObj->character->message != '')
          print('<div class="banner">'.$ctrObj->character->message.'</div>');
        if ($ctrObj->message != '')
          print('<div class="banner">'.$ctrObj->message.'</div>');
        ?>
        <?= $content ?>
        <? profile_point('- content'); ?>
    </div>
    <script type="text/javascript" src="custom/skinnytip.js"></script>
    
    <script>
    // facebook frame check
    if(window.name == '')
    {
      document.location.replace('<?= $config['fb']['url'].$_REQUEST['controller'].'/'.$_REQUEST['action'] ?>');
    }
    </script>
  <script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-426761-10");
pageTracker._trackPageview();
} catch(err) {}</script>
  </body>
</html><?
 
  profile_point('- end');
  print(ob_get_clean());
  profile_point('- write out buffer');
  #AuditLog('page:'.$_ENV['REQUEST_URI'], '');
?>
